Visual Studio builds: Adapt to new glib-mkenums
authorChun-wei Fan <fanchunwei@src.gnome.org>
Tue, 1 Aug 2017 08:05:57 +0000 (16:05 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Tue, 1 Aug 2017 08:26:43 +0000 (16:26 +0800)
glib-mkenums is now done in Python, but since the Visual Studio build
environment (cmd.exe) does not support shebang lines, we need to call
the interpretor explicitly to run the script.

This means that we need to update on how we generate
gsk/gskenumtypes.[c|h] in our projects, as at this point GTK+-3.91.x
does not require a GLib installation that ships with the Python-fied
glib-mkenums.  As a result, we adapt to this by first using Python
to call glib-mkenums.  If this fails (where the output file becomes 0
in size), then we use PERL to call the glib-mkenums script.  Note that
during the build this will cause a warning message to be displayed,
stating that '&' cannot be found, but due to the way Windows .bat script
are done, we need to live with that until a solution can be found on
this.

This is likely a problem that does not exist in the Meson builds, as
Meson will take care of calling the interpretor for us by looking at
the shebang lines for our case.

Also, clean up the .batin Windows batch script that is used to call
glib-mkenums by using a for loop in there.

win32/gen-enums.batin
win32/vs12/gsk-4.vcxprojin
win32/vs12/gtk4-gen-srcs.props

index 64f2cd8666647fd0d0253dd492781cf450f7152f..a99b60a308d07763325cdb8e2b304a8232ec8e03 100644 (file)
@@ -5,12 +5,14 @@ cd ..\gsk
 if exist gskenumtypes.h del gskenumtypes.h
 if exist gskenumtypes.c del gskenumtypes.c
 
-call perl %1\bin\glib-mkenums ^
---template gskenumtypes.h.template ^
+for %%f in (gskenumtypes.h gskenumtypes.c) do ^
+%2\python %1\bin\glib-mkenums ^
+--template %%f.template ^
 #include "gsk.enum.headers"
-&1> gskenumtypes.h
+&1> %%f
 
-call perl %1\bin\glib-mkenums ^
---template gskenumtypes.c.template ^
+for %%f in (gskenumtypes.h gskenumtypes.c) do ^
+if %%~zf EQU 0 perl %1\bin\glib-mkenums ^
+--template %%f.template ^
 #include "gsk.enum.headers"
-&1> gskenumtypes.c
+&1> %%f
index db6f34dd1f4ec5f575b3830979805da68ea486de..5b12f4ab73117bbcdd53bb50fad221ac13a12041 100644 (file)
   </ItemDefinitionGroup>
   <ItemGroup>
     <CustomBuild Include="..\..\gsk\gskenumtypes.c.template">
-      <Message Condition="'$(Configuration)'=='Debug'">Generating GSK enumeration sources...</Message>
-      <Command Condition="'$(Configuration)'=='Debug'">$(GenGSKEnumSrcs)</Command>
-      <Outputs Condition="'$(Configuration)'=='Debug'">..\..\gsk\gskenumtypes.h;..\..\gsk\gskenumtypes.c;%(Outputs)</Outputs>
-      <Message Condition="'$(Configuration)'=='Debug_Vulkan'">Generating GSK enumeration sources...</Message>
-      <Command Condition="'$(Configuration)'=='Debug_Vulkan'">$(GenGSKEnumSrcs)</Command>
-      <Outputs Condition="'$(Configuration)'=='Debug_Vulkan'">..\..\gsk\gskenumtypes.h;..\..\gsk\gskenumtypes.c;%(Outputs)</Outputs>
-      <Message Condition="'$(Configuration)'=='Release'">Generating GSK enumeration sources...</Message>
-      <Command Condition="'$(Configuration)'=='Release'">$(GenGSKEnumSrcs)</Command>
-      <Outputs Condition="'$(Configuration)'=='Release'">..\..\gsk\gskenumtypes.h;..\..\gsk\gskenumtypes.c;%(Outputs)</Outputs>
-      <Message Condition="'$(Configuration)'=='Release_Vulkan'">Generating GSK enumeration sources...</Message>
-      <Command Condition="'$(Configuration)'=='Release_Vulkan'">$(GenGSKEnumSrcs)</Command>
-      <Outputs Condition="'$(Configuration)'=='Release_Vulkan'">..\..\gsk\gskenumtypes.h;..\..\gsk\gskenumtypes.c;%(Outputs)</Outputs>
+      <Message Condition="'$(Platform)'=='Win32'">Generating GSK enumeration sources...</Message>
+      <Command Condition="'$(Platform)'=='Win32'">$(GenGSKEnumSrcs)</Command>
+      <Outputs Condition="'$(Platform)'=='Win32'">..\..\gsk\gskenumtypes.h;..\..\gsk\gskenumtypes.c;%(Outputs)</Outputs>
+      <Message Condition="'$(Platform)'=='x64'">Generating GSK enumeration sources...</Message>
+      <Command Condition="'$(Platform)'=='x64'">$(GenGSKEnumSrcsX64)</Command>
+      <Outputs Condition="'$(Platform)'=='x64'">..\..\gsk\gskenumtypes.h;..\..\gsk\gskenumtypes.c;%(Outputs)</Outputs>
     </CustomBuild>
     <CustomBuild Include="..\..\gsk\gsk.gresource.xml">
-      <Message Condition="'$(Configuration)'=='Debug'">Generating GSK resource sources...</Message>
-      <Command Condition="'$(Configuration)'=='Debug'">$(GenGSKRsrcSrcs)</Command>
-      <Outputs Condition="'$(Configuration)'=='Debug'">..\..\gsk\gskresources.h;..\..\gsk\gskresources.c;..\..\gsk\gsk.gresource.xml;%(Outputs)</Outputs>
-      <Message Condition="'$(Configuration)'=='Debug_Vulkan'">Generating GSK resource sources...</Message>
-      <Command Condition="'$(Configuration)'=='Debug_Vulkan'">$(GenGSKRsrcSrcs)</Command>
-      <Outputs Condition="'$(Configuration)'=='Debug_Vulkan'">..\..\gsk\gskresources.h;..\..\gsk\gskresources.c;..\..\gsk\gsk.gresource.xml;%(Outputs)</Outputs>
-      <Message Condition="'$(Configuration)'=='Release'">Generating GSK resource sources...</Message>
-      <Command Condition="'$(Configuration)'=='Release'">$(GenGSKRsrcSrcs)</Command>
-      <Outputs Condition="'$(Configuration)'=='Release'">..\..\gsk\gskresources.h;..\..\gsk\gskresources.c;..\..\gsk\gsk.gresource.xml;%(Outputs)</Outputs>
-      <Message Condition="'$(Configuration)'=='Release_Vulkan'">Generating GSK resource sources...</Message>
-      <Command Condition="'$(Configuration)'=='Release_Vulkan'">$(GenGSKRsrcSrcs)</Command>
-      <Outputs Condition="'$(Configuration)'=='Release_Vulkan'">..\..\gsk\gskresources.h;..\..\gsk\gskresources.c;..\..\gsk\gsk.gresource.xml;%(Outputs)</Outputs>
+      <Message>Generating GSK resource sources...</Message>
+      <Command>$(GenGSKRsrcSrcs)</Command>
+      <Outputs>..\..\gsk\gskresources.h;..\..\gsk\gskresources.c;..\..\gsk\gsk.gresource.xml;%(Outputs)</Outputs>
     </CustomBuild>
   </ItemGroup>
   <ItemGroup>
index c611d740aa4e5322e0de97a066508deb1df6ea57..4837210044d429d17db73e6c317e5cd9c9adbe13 100644 (file)
@@ -45,7 +45,8 @@ echo $(Configuration) &gt; ..\..\MSVC_$(Configuration)_Vulkan
     <GenerateGtkWin32Manifest>$(PythonDir)\python ..\replace.py --action=replace-var --input=..\..\gtk\libgtk4.manifest.in --output=..\..\gtk\libgtk4.manifest --var=EXE_MANIFEST_ARCHITECTURE --outstring=*</GenerateGtkWin32Manifest>
     <GenerateGtkWin32ManifestX64>$(PythonDirX64)\python ..\replace.py --action=replace-var --input=..\..\gtk\libgtk4.manifest.in --output=..\..\gtk\libgtk4.manifest --var=EXE_MANIFEST_ARCHITECTURE --outstring=*</GenerateGtkWin32ManifestX64>
     <CopyDemosH>copy ..\..\demos\gtk-demo\demos.h.win32 ..\..\demos\gtk-demo\demos.h</CopyDemosH>
-    <GenGSKEnumSrcs>(cd ..) &amp; (call gen-enums.bat $(GlibEtcInstallRoot)) &amp; (cd $(SolutionDir))</GenGSKEnumSrcs>
+    <GenGSKEnumSrcs>(cd ..) &amp; (call gen-enums.bat $(GlibEtcInstallRoot) $(PythonDir)) &amp; (cd $(SolutionDir))</GenGSKEnumSrcs>
+    <GenGSKEnumSrcsX64>(cd ..) &amp; (call gen-enums.bat $(GlibEtcInstallRoot) $(PythonDirX64)) &amp; (cd $(SolutionDir))</GenGSKEnumSrcsX64>
     <GenGSKRsrcSrcs>
 echo ^&lt;?xml version='1.0' encoding='UTF-8'?^&gt; &gt; ..\..\gsk\gsk.gresource.xml
 echo ^&lt;gresources^&gt; &gt;&gt; ..\..\gsk\gsk.gresource.xml
@@ -97,6 +98,9 @@ $(GlibEtcInstallRoot)\bin\glib-compile-resources.exe --sourcedir=..\..\gsk --c-n
     <BuildMacro Include="GenGSKEnumSrcs">
       <Value>$(GenGSKEnumSrcs)</Value>
     </BuildMacro>
+    <BuildMacro Include="GenGSKEnumSrcsX64">
+      <Value>$(GenGSKEnumSrcsX64)</Value>
+    </BuildMacro>
     <BuildMacro Include="GenGSKRsrcSrcs">
       <Value>$(GenGSKRsrcSrcs)</Value>
     </BuildMacro>